#ifndef _SGF_IENTITY_H_
#define _SGF_IENTITY_H_

#include "SaveData.h"
#include "fastsig/fastsig.hpp"
#include <list>

namespace SGF
{
	class MapState;

	class SGF_API IEntity: public fastsig::trackable
	{
	friend class MapState;
	public:
		IEntity();
		virtual ~IEntity();
		IEntity* clone() const;

		virtual void onStateBegin();
		virtual void onStateEnd();
		virtual void onUpdate(Ogre::Real timeSinceLastFrame);
		virtual void onChildAttached(IEntity* child);
		virtual void onChildDetached(IEntity* child);
		void attachTo(IEntity* parent);
		IEntity* getParent();
		virtual void onLoad(const SaveData& saveData);
		virtual void onSave(SaveData& saveData) const;

		virtual void setNode(Ogre::SceneNode* newNode);
		virtual const Ogre::Vector3 getRotation() const;
		virtual void setRotation(const Ogre::Vector3& rot);
		virtual const Ogre::Vector3& getPosition() const;
		virtual void setPosition(const Ogre::Vector3& pos);
		virtual const Ogre::Vector3&  getScale() const;
		virtual void setScale(const Ogre::Vector3& scale);

	protected:
		virtual void onCreate()=0;

		MapState* map;
		std::list<IEntity*> childEntityList;
		IEntity* parent;
		bool active;
		fastsig::connection updateConnection;
		Ogre::SceneNode* node;
	};
}

#endif